package com.yfore.jfinal.jsql.plugin.core;

import java.util.HashMap;
import java.util.Map;

/**
 * SQL语句与ID映射关系
 * @author farmer
 *
 */
public class SqlMapping {
	
	private static Map<String, String> sqlMap = new HashMap<String, String>();
	
	/**
	 * PUT
	 * @param key
	 * @param value
	 */
	public static void put(String key , String value){
		if(null !=sqlMap.get(key)){
			throw new RuntimeException("SQL语句的ID:"+key+"已经存在!");
		}
		sqlMap.put(key, value);
	}
	
	
	/**
	 * 获取SQL
	 * @param key
	 * @return
	 */
	public static String get(String key){
		String value = sqlMap.get(key);
		if(null == value){
			throw new RuntimeException("SQL语句的ID:"+key+"不存在!");
		}
		return value;
	}
}
